Huawei’s Connect API Service. AppGallery Connect API Overview

您所在的位置:网站首页 AppGallery Connect API Huawei’s Connect API Service. AppGallery Connect API Overview

Huawei’s Connect API Service. AppGallery Connect API Overview

#Huawei’s Connect API Service. AppGallery Connect API Overview | 来源: 网络整理| 查看: 265

Huawei’s Connect API ServicePhoto by Marvin Meyer on UnsplashAppGallery Connect API Overview

The AppGallery Connect API provides RESTful APIs that can be used to customize services provided by AppGallery Connect or implement process automation, thereby improving your work efficiency.

Publishing API

The Publishing API allows you to:

Upload app information, including the app copyright information.Modify basic app information, including the app name and description.Add or update version information, including the app screenshot and video.Release and update apps and submit apps for approval.

The Publishing API cannot be used to create apps. You need to create apps in AppGallery Connect first. Then you can call the Publishing API to update app information, upload app packages, and perform other app-related operations. The Publishing API cannot be used to set app content ratings. Therefore, you need to set content ratings for apps in AppGallery Connect before submitting the apps for approval.

Reports API

You can use the Reports API to query most reports in AppGallery Connect. Similar to report query in AppGallery Connect, you can specify the date range and add a filter to query reports through the Reports API. The query result is returned as CSV or Excel files.

Project Management API

The Project Management API is provided for you to access and manage project information, including:

Obtaining the development team list.Obtaining brief information of apps in a project.Obtaining the SDK configuration file for an app in a project.

Using the API, your users can access and manage their projects without signing in to AppGallery Connect, improving their development efficiency.

Comments API

The Comments API allows you to automatically obtain comment data from AppGallery Connect and analyze the data using your own or a third-party comment analysis system (such as Braze) for refined operations or reply to comments.

PMS API

The Product Management System (PMS) API allows you to create and update product and promotion information, including the product price and display language, implementing in-app management of product prices and display languages for localized pricing for global locations.

Getting Started

Before starting development based on the AppGallery Connect API, you can refer to Getting Started to understand the basic development preparations and process.

You can refer to the sample code provided in Sample Code of the Connect API when programing your app.

APIs of the Earlier Version

Currently, the latest version of the Publishing API is V2. The V1 version has been brought offline. Please upgrade to the V2 version as soon as possible.

AppGallery Connect API Getting Started

To call the AppGallery Connect API, you need to obtain authorization from the AppGallery Connect server in advance using either of the following modes:

API client mode: Access APIs as an app according to the permissions assigned to your API client role. Use this mode when your user needs to connect their own IT system to AppGallery Connect.OAuth client mode: The OAuth client enables your app to provide various management services for users, who can be Huawei developers. Your users can sign in to your app using HUAWEI IDs and access APIs according to the permissions assigned to the role of their account in their team. Use this mode when you are developing a third-party IDE or development tool that needs to be connected to AppGallery Connect.API Client Mode

To call the AppGallery Connect API in the API client mode, you need to manage your API client in AppGallery Connect. An API client can be managed only by your team account holder. The basic process is as follows:

Creating an API clientObtaining the token for accessing the APIAccessing the APICreating an API Client

An API client is an identity credential used by AppGallery Connect to manage user access to the AppGallery Connect API. You can create different API clients for different roles. Users with different roles can access the AppGallery Connect API with the corresponding permissions. Before accessing an API, you must create an API client with the permission for accessing the API. The procedure is as follows:

Sign in to AppGallery Connect and select Users and permissions.Go to Api Key > AppGalleryConnect API from the navigation tree on the left and click Create.Set Name to a customized client name, set Roles to the corresponding role, and click Confirm.

4. After the client is successfully created, record the values of Client ID and Key in the client information list.

After an API client is created, you need to obtain the token for accessing the API based on the client ID and key.

Obtaining the Token for Accessing the API

After an API client is created, the API client needs to be authenticated in AppGallery Connect. After the authentication is successful, the API client obtains an access token for accessing the AppGallery Connect API. With this access token, you can access the AppGallery Connect API.

To obtain an access token, you need to add the code for calling the Obtaining a Token API to your app program.

After obtaining an access token, you can use the access token for identity authentication when accessing the AppGallery Connect API. The default validity period of an access token is 48 hours. If an access token expires, you need to obtain a new access token.

Accessing the API

After obtaining an access token, you can use the access token to call the AppGallery Connect API to complete function development. For details about the API call method, please refer to the API reference.

An API client that needs to access the AppGallery Connect API must have the API access permission.

Sample Project

You can refer to the sample code provided in Sample Code of the Connect API when programing your app.

OAuth Client Mode

To call the AppGallery Connect API in the OAuth client mode, you need to obtain an authorization credential for API access from Huawei. The API access scope is determined by the user’s role in their team. The basic process is as follows:

Applying for the API scopeIntegrating HUAWEI Account KitObtaining a user authorization codeAccessing the APIApplying for the API Scope

If you want to use the OAuth client mode to call the AppGallery Connect API, fill in an application form and send it to [email protected]. In the form, you can specify the APIs that you need to access in Scope.

Application template:

Title: [OAuth service application]-[Company name]-[Developer account]-[Server app ID]Application form: AppGallery Connect API Scope Application Form.

The following table describes the API scopes provided by AppGallery Connect.

Integrating HUAWEI Account Kit

HUAWEI Account Kit implements the OAuth client mode of the AppGallery Connect API. To use the mode, you need to integrate HUAWEI Account Kit first.

If your app is an Android app, please refer to HUAWEI Account Kit Development Process.If your app is a web app, please refer to Preparing for Web App Development.Obtaining a User Authorization Code

After integrating HUAWEI Account Kit, you can obtain an access token upon successful sign-in authorization for API access in OAuth client mode.

If your app is an Android app, please refer to Signing In with HUAWEI ID (Authorization Code).If your app is a web app, please refer to Obtaining an Access Token by Authorization Code.Accessing the API

After obtaining an access token, you can use the access token to call the AppGallery Connect API to complete function development. For details about the API call method, please refer to the API reference.

Note that your user must be authorized to call a specific API. If API calls fail due to insufficient permissions, you need to instruct your user to apply for the role with the required permission from their team.

Development Overview

You can use the Publishing API to manage and release apps in AppGallery Connect in RESTful mode. A typical process of developing an app based on the Publishing API is as follows:

Create an app. You need to manually create an app in AppGallery Connect.Develop the app. You need to complete app development in your development environment.Complete app information. You need to call the Publishing API to update and complete information about the app created in AppGallery Connect.Upload app files. You need to call the Publishing API to upload the software package (such as APK, RPK, or AAB file), icon, introduction image, video, and other files of the app.Release the app. You need to call the Publishing API to submit the app for release.Creating an App

You cannot directly use the Publishing API to create an app but need to create an app in AppGallery Connect first. For details, please refer to Creating an App. You only need to create an app. Other app management operations can be performed through the Publishing API.

Publishing APIDeveloping the App

After an app is created, you can develop the app based on the common process. This section describes only the method of managing apps based on the Publishing API. You need to complete app function development by yourself.

Completing App Information

After an app is developed, you can call the Publishing API to complete the app details in AppGallery Connect, including:

Basic app information, including the language, category, country code, and developer information. You can call the Updating Basic App Information API to modify basic app information. Before modifying basic app information, you need to call the Querying the App ID Corresponding to an App Package Name API to query the app ID. To determine whether the current app information is correct, you can call the Querying App Information API to query the current app details.Multi-language app information. You can call the Updating Multi-language App Information API to add or modify app information in each language. The app information in the default language is mandatory. To delete app information in a certain language, you can call the Deleting Multi-language App Information API.

Note that the content rating information about an app cannot be completed through the Publishing API. You must configure the content rating information in AppGallery Connect. For details, please refer to Changing the Content Rating of an App.

Uploading App Files

After completing app information, you need to prepare related app files, such as the APK, RPK, or AAB file, icon, introduction image, and video of the app. Through the Publishing API, app files are uploaded from one server to another. Therefore, compared with app file upload in AppGallery Connect, that through the Publishing API is faster and is not restricted by the network where your PC is located. The app file upload procedure is as follows:

Obtain the file upload URL. Before uploading a file, you need to call the Obtaining the File Upload URL API to obtain the file upload URL.Upload the app file. You need to call the Uploading a File API to upload the file to Huawei file server. If the APK or RPK file is too large, you can call the Uploading a File by Chunk API to upload the file by chunk.Update app file information. After an app file is uploaded, you can call the Updating App File Information API to write the file information to AppGallery Connect.Releasing the App

After completing app file information, you can submit the app for release. After successful release, your app will be displayed in AppGallery. Currently, the Publishing API supports the following app release methods:

Directly submit the app for release. After app files are uploaded, you can call the Submitting an App for Release API to directly submit a release request.Submit the app for release in download mode. If your app software package is stored on your own server, you can call the Submitting an App for Release in Download Mode API to instruct Huawei server to download the APK or RPK file of the app from the URL carried in the API call request and start app release. After the app is released, Huawei server calls the Sending an App Release Notification API to notify your server of the release result. This method applies only to apps whose release countries or regions include Chinese mainland or apps developed by developers in Chinese mainland.

To release an app by phase, you can call the Updating Release by Phase API to change the phase-based release mode, or call the Changing Phase-based Release Status API to change the current phase-based release status.

Completing App Information

Much basic information about apps created in AppGallery Connect is empty by default. This section describes how to complete app information through the Publishing API.

Querying an App ID Based on the App Package Name

An app ID is a unique ID allocated by AppGallery Connect to a created app. It is required during app information query or update through the Publishing API. If you do not know the ID of an app, you can call the Querying the App ID Corresponding to an App Package Name API to query the ID based on the app package name configured in AppGallery Connect during app creation. You can query multiple app IDs at a time.

Querying App Information

Before or after app information update, you can call the Querying App Information API (GET mode) to query the app details, so that you can determine whether the update is required or successful. The app ID is that returned by the Querying the App ID Corresponding to an App Package Name API.

Updating Basic App Information

You can call the Updating Basic App Information API (PUT mode) to update basic app information, for example, whether the app is free of charge or whether the app needs to be used over the network.

Updating Multi-language App Information

If your app supports multiple languages, you need to configure the app information in each language, including the detailed app description, brief app introduction, and new version introduction. You can call the Updating Multi-language App Information API to configure multi-language app information. In this API, you can specify the language of the app information to update. If app information in the specified language does not exist, the API adds it.

If app information in a language is incorrect or unnecessary, you can call the Deleting Multi-language App Information API to delete the information.

Changing the Content Rating of an AppSign in to AppGallery Connect and select My apps.Find your app in the list and click the app name.Click the Distribute tab and go to Release app > Draft from the navigation tree on the left.On the right of the page, check whether the release countries or regions of the app are selected for Countries/Regions released. If no country or region is selected, you need to manually select one or more

5. In the Content Rating area, click Apply Ratings. In the pop-up window that is displayed, select a content rating.

Uploading App Files

After completing app information, you need to prepare related app files, including:

App package, that is, the APK, RPK, or AAB file of the app. You need to upload the package of an app only when you want to directly submit the app for release.Other files, including multimedia files such as the app icon, introduction image, and video. You must upload these files by following instructions in this section.

App files can be uploaded in common mode or by chunk. Before uploading app files in either mode, you need to obtain the file upload URL from Huawei server. After uploading app files, you need to update app file information.

Obtaining the File Upload URL

Before uploading app files, you need to call the Obtaining the File Upload URL API to obtain an authentication code and the file upload URL. The authentication code is used for security authentication during file upload. Huawei server may allocate a file upload URL based on user site information. The uploaded files will be saved at the URL. When you submit the app for release, Huawei server obtains the files from the URL to start release.

Uploading Files

After obtaining the file upload URL, you can call the Uploading a File API to upload app files, including the APK, RPK, or AAB file, introduction image, and preview video of the app. Take the following precautions when using this API:

Files must be encoded in multipart/form-data format and attached to an HTTPS packet.The Content-Type field is encoded in multipart/form-data format. The value of each form field does not need to be encoded, but charset of each form field must be UTF-8.The maximum size is 2 MB for an image, 500 MB for a video, 4 GB for an APK file, 10 MB for an RPK file, and 200 MB for an AAB file. The timeout interval for file upload is 2 hours. The APK or RPK file can also be uploaded by chunk through the Uploading Files by Chunk API.APK, RPK, PDF, JPG, JPEG, PNG, BMP, MP4, MOV, and AAB files are supported.Uploading a File by Chunk

If the APK or RPK file is too large, you can call the Uploading a File by Chunk API to upload the file by chunk. The upload URL is specified by the chunkUploadUrl parameter returned by the Obtaining the File Upload URL API. The upload mode is used for chunk upload. Upon the upload of each chunk, it is recommended that the check mode be used to check whether the upload is successful. After all chunks are uploaded, it is recommended that the merge mode be used to merge all chunks.

Updating App File Information

After being uploaded, files are stored on Huawei server but the file information about the app is not updated. You need to call the Updating App File Information API to write file information into the app. If fileType is set to 5, the app package, for example, an RPK, APK, or AAB file, needs to be updated. If you need to update an AAB file, you can pass pkgVersion after updating the app file information so that you can query the compilation status of the AAB file later.

Releasing the App

After completing app information, you can submit the app for release. After successful release, your app will be displayed in AppGallery. Currently, the Publishing API supports the following app release methods:

Directly submit the app for release. You can upload the app software package to Huawei server and Huawei server directly submits the app for release using the software package.Submit the app for release in download mode. The app software package is stored on your server, and Huawei server downloads the software package and then submits the app for release.Directly Submitting the App for Release

After an app software package is uploaded to Huawei server, you can call the Submitting an App for Release API to submit the app for release. If you set the releaseType parameter to release the app by phase, you can change the mode and status of release by phase during the release. For details, please refer to Releasing the App by Phase.

If you are using the App Signing service, AppGallery Connect will compile your updated app package. If you choose to release your app before the package compilation completes, error code 204144660 will be returned.

If your app package is in the AAB format, you can pass pkgVersion in FileInfo when calling the Updating App File Information API. Then you can call the Querying the Compilation Status of an App Package API and pass pkgVersion to check whether the app package compilation is complete.If your app package is not an AAB package, wait for a while after receiving the error code 204144660 and submit an app release application again.Submitting an App for Release in Download Mode

If your app software package is stored on your server, you can call the Submitting an App for Release in Download Mode API to instruct Huawei server to download the software package from your server and start app release. The software download URL must be carried in the API call request.

After the app is released, Huawei server calls the Sending an App Release Notification API to notify your server of the release result. The notification contains a signature, and you need to verify the signature to determine the notification correctness. A public key is required to verify the signature. For details about how to obtain such a public key, please refer to Obtaining a Public Key for Signature Verification. The sample code for signature verification is as follows:

Releasing the App by Phase

If you set the releaseType parameter to release the app by phase, you can call the Changing Phase-based Release Status API to change the release status to SUSPEND during phase-based release and change the release status to RELEASE after the phase-based release is paused. You can also call the Updating Release by Phase API to change the phase-based release mode to 1.

Reports APIDevelopment Overview

You can use the Reports API to query most analysis data in AppGallery Connect, including report data such as download and installation, reservation, user group award granting, new and retained user, in-app payment, paid download, coupon activity, and installation failure data. A typical process of developing an app based on the Reports API is as follows:

View report data. Before obtaining a report of an app, you must ensure that the corresponding report data of the app exists in AppGallery Connect and the app must have been released and promoted.Obtain the report download URL. You need to call the Reports API to obtain the download URL of the report CSV or Excel file.Download the report. You need to manually download the CSV or Excel file based on the obtained report download URL.Viewing Report Data

Before obtaining a report of an app, you must ensure that the corresponding report data of the app exists in AppGallery Connect and the app must have been released and promoted. To query existing report data in AppGallery Connect, perform the following steps:

Sign in to AppGallery Connect and select Analytics.Find your app in the list and click the app name.View report data on pages such as Distribution Analysis and Operation Analysis.Obtaining the Report Download URL

You can call the Reports API to obtain the download URL of the report CSV or Excel file.

Before calling the Reports API, you must ensure that an API client has been created and an access token has been obtained. For details, please refer to Getting Started.

Downloading the Report

After obtaining the report download URL, you can directly download the report CSV or Excel file from the URL. The file contains detailed report data.

Development Example

This section uses the Obtaining the Paid Download Report URL API as an example to describe Reports API-based app development. The processes of calling other APIs of the Reports API are similar.

1. Perform server authorization by referring to Getting Started. For example, to use the API client mode, you need to create an API client of the required role and obtain an access token used for authentication.

2. Call the Obtaining the Paid Download Report URL API to obtain the report download URL.

3. Download the report CSV or Excel file from the obtained report download URL.

Project Management APIDevelopment Overview

You can call the Project Management API to obtain your users’ project and configuration information from AppGallery Connect.

The basic process is as follows:

Obtaining a user authorization code: Obtain the authorization for accessing the Project Management API.Obtaining the team list: Obtain the current team list of your user to allow them to switch between teams. You can record the user’s selection so that the selected team will be used by default next time.Obtaining the ID of an app: Query the information about the app manually created by a user in AppGallery Connect based on the app package name entered by the user or automatically identified.Obtaining the configuration file: Obtain the configuration file required for integrating Huawei Kits based on the obtained app ID to provide better Huawei service integration experience for your users.Obtaining a User Authorization Code

The Project Management API can be accessed only through the OAuth client mode. You need to obtain the user’s access token generated after HUAWEI ID sign-in and authorization.

Obtaining the Team List

If you need to provide the team account management function, call the Obtaining the Team List API to enable your users to switch between teams. The sample code is as follows:

Obtaining the ID of an App

Then you can call the Obtaining App Brief Information API to obtain the app ID from AppGallery Connect based on the app package name for subsequent app management. The sample code is as follows:

Obtaining the Configuration File

You can call the Obtaining the Configuration File API to obtain the SDK integration configuration file agconnect-services.json of the app based on the app ID that you just obtained, helping your users integrate Huawei services more easily. The sample code is as follows:

Comments APIDevelopment Overview

You can call the Comments API to obtain comment data from AppGallery Connect and analyze the data using your own or a third-party comment analysis system (such as Braze) for refined operations or reply to comments. A typical development process using the Comments API is as follows:

Obtaining authorization from the server: Obtain authorization from the server in the API client mode.Querying the comment list: Query the comment list of your app by criteria including the app ID (mandatory), original comment content, commenting time period (mandatory), country/region (mandatory), rating, device model, APK version, review status, reply status, and language.Querying details about a comment: Query details about a comment and its replies based on the comment ID.Replying to comments and replies: You can reply to a comment (once), or to a reply (multiple times and the content can be modified). Your reply is displayed both in AppGallery Connect and on AppGallery.

During the development, you can access the Comments page in AppGallery Connect, check the comments, and verify the API implementation. For details, please refer to Comments.

Obtaining Authorization from the Server

The Comments API can be accessed only through the API client mode. To access the API, you need to obtain authorization from the server. The authorization process consists of API client creation nd access token obtaining. For details, please refer to Getting Started.

Querying the Comment List

You can call the Querying the Comment List API to obtain the comment list based on specified criteria. The sample code is as follows:

The response is a JSON string containing a list of comments on the app.

The results in the list are sorted by the value of the sort parameter in the request.The page number to be queried is specified by the page parameter in the request.The number of comments displayed on each page is defined by the limit parameter in the request. The default value is 20 and the maximum value is 100. The following is an example of the query result:Querying Details About a Comment

You can call the Querying Details About a Comment API to obtain the content and replies of a specified comment based on the comment ID. The sample code is as follows:

The response is a JSON character string containing the content and all replies (either by you or by other users) of the comment. The following is an example:

Replying to a Comment

You can call the Replying to a Comment API to reply to a user’s comment. The reply will be made based on the obtained comment ID (reviewId). The sample code is as follows:

Your app ID will be automatically used as your nickname, which will be displayed together with your developer ID in the reply information. For approved user comments, your replies will be directly displayed on HUAWEI AppGallery to all users. For user comments that have not been approved, you can reply to the comments, but the replies are visible only to the users making comments. Once the user comments are approved, your replies are visible to all users.

The following is an example of the body in the POST request for replying to a comment:

PMS API

You can manage the prices and languages of in-app products through the PMS API to implement localized pricing for all supported locations.

The basic development process is as follows:

Obtaining authorization from the AppGallery Connect server: You can obtain authorization either in API client mode or OAuth client mode.Creating products: You can create a single product or create multiple products in batches. You can also manage your products in AppGallery Connect by referring to In-app Product Management.Querying and updating products: After a product is successfully created, you can query or update the product information.Managing product statuses: You can activate or deactivate a product. An activated product is available for sale. Deactivating a product will remove it from sale and immediately end all promotions related to the product. Subscriptions that already take effect will not expire when the corresponding product is removed. You are advised to provide services related to the subscriptions till the subscription end time arrives.Managing product promotions: You can create, update, and query product promotion information for subscription and non-subscription products, including the promotion time period, applicable countries/regions, and promotional prices.Creating ProductsCreating a Non-Subscription Product

Non-subscription products are classified into the following:

Consumables: Products that are intended to be consumed and can be purchased again, such as coins and items in games.Non-consumables: Products that will not expire or get used up once purchased, such as ads removal and professional edition.

You can call the Creating a Product API to to create a single product or call the Creating Products in Batches API to create multiple products at a time. In either API, you can set the purchaseType parameter to consumable or non_consumable. In addition, you can specify the product promotion information in the batch product creation API.

Creating a Non-Subscription Product

Non-subscription products are classified into the following:

Consumables: Products that are intended to be consumed and can be purchased again, such as coins and items in games.Non-consumables: Products that will not expire or get used up once purchased, such as ads removal and professional edition.

You can call the Creating a Product API to to create a single product or call the Creating Products in Batches API to create multiple products at a time. In either API, you can set the purchaseType parameter to consumable or non_consumable. In addition, you can specify the product promotion information in the batch product creation API.

The following is the sample code for creating products in batches:

Creating a Subscription Product

A subscription products is auto-renewable. Users can purchase access to value-added functions or content in a specified period of time. The subscriptions automatically renew on a recurring basis until users decide to cancel, for example, monthly membership of a video app.

Subscriptions are managed by subscription group. Before creating a subscription product, you need to create a subscription group by calling the Creating a Product Subscription Group API. When calling either the Creating a Product or Creating Products in Batches API, you need to specify the subscription group to which a product belongs (subGroupId) and set the purchaseType parameter to auto_subscription. In addition, you can specify the product promotion information in the batch product creation API.

The sample code for creating a product subscription group is as follows:

In addition to the API for creating a product subscription group, the PMS API provides the Updating a Product Subscription Group and Querying a Product Subscription Group APIs for you to use as required.

Thanks for your time. Hope to see you in the next article. :)



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3